<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%@ page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"%>
<%@ page import="org.springframework.security.core.AuthenticationException"%>

<div dojoType="dijit.layout.BorderContainer" design="headline" gutters="true" liveSplitters="true" style="width: 100%; height: 100%; border: 0;">
	<div dojoType="dijit.layout.ContentPane" splitter="true" region="left" style="width: 200px; padding-left: 60px; border: 0; background-color: transparent;">
		<p>Valid username/passwords are:</p>
		<ul>
			<li>keith/melbourne</li>
			<li>erwin/leuven</li>
			<li>jeremy/atlanta</li>
			<li>scott/rochester</li>
		</ul>
	</div>
	<div dojoType="dijit.layout.ContentPane" splitter="true" region="center" style="padding: 5px; width: 600px; height: 400px; ">
		<c:if test="${not empty param.login_error}">
			<div class="error">
				Your login attempt was not successful, try again.<br />
				<br /> Reason:
				<%=((AuthenticationException) session
						.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY))
						.getMessage()%>
			</div>
		</c:if>
    <c:if test="${empty param.login_error}">
      <div class="loginForm" style="height: 89px;"></div>
    </c:if>
		<form name="f" action="<c:url value="/loginProcess" />" method="post">
			<fieldset style="border: 0; padding-left: 60px;">
				<legend>Login Information</legend>
				<p>
					<label for="j_username">User:</label> <br /> <input type="text" name="j_username" id="j_username"
						<c:if test="${not empty param.login_error}">value="<%= session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"</c:if> value="erwin" />
				</p>
				<script type="text/javascript">
					Spring.addDecoration(new Spring.ElementDecoration({
						elementId : "j_username",
						widgetType : "dijit.form.ValidationTextBox",
						widgetAttrs : {
							required : true
						}
					}));
				</script>
				<p>
					<label for="j_password">Password:</label> <br /> <input type="password" name="j_password" id="j_password" value="leuven" />
				</p>
				<script type="text/javascript">
					Spring.addDecoration(new Spring.ElementDecoration({
						elementId : "j_password",
						widgetType : "dijit.form.ValidationTextBox",
						widgetAttrs : {
							required : true
						}
					}));
				</script>
				<p>
					<input type="checkbox" name="_spring_security_remember_me" id="remember_me" /> <label for="remember_me">Don't ask for my password for two weeks:</label>
				</p>
				<script type="text/javascript">
					Spring.addDecoration(new Spring.ElementDecoration({
						elementId : "remember_me",
						widgetType : "dijit.form.CheckBox"
					}));
				</script>
				<p>
					<button id="submit" type="submit">Login</button>
					<script type="text/javascript">
						Spring.addDecoration(new Spring.ValidateAllDecoration({
							event : 'onclick',
							elementId : 'submit'
						}));
					</script>
				</p>
			</fieldset>
		</form>
	</div>
</div>

